<?php
// khoi tao model Product khi co request den trang nay
chk_login();
chk_permision();
include('modules/product/model.php');
$productModel = new productModel(); 
$a = @$_GET['act'];
switch ($a){
	case 'detail':
		$id = @$_GET['id'];
		if (!$id) {
			header("Location: index.php?mod=product");
		}
		$product = $productModel->get_product_by_id2($id);
		include('modules/product/detail.php');
		break;
	case 'insert':
		include('modules/product/insert.php');
		break;
	case 'xl_insert':
		$productModel->xl_insert();
		break;
	case 'edit':
		$id = @$_GET['id'];
		if (!$id) {
			header("Location: index.php?mod=product");
		}
		$product = $productModel->get_product_by_id($id);
		include('modules/product/edit.php');
		break;
	case 'xl_edit':
		$productModel->xl_edit();
		break;
	case 'delete':
		if (isset($_GET['id']))
			$id = $_GET['id'];
		else
			$id = '';
		$str = "DELETE FROM tbl_product WHERE id= $id";
		$result= mysql_query($str);
		if($result)
			header('location:index.php?mod=product');
		else
			echo "Xoa that bai!".mysql_error();
		break;		
	default:
		include('modules/product/list.php');
		break;
}
?>